<template>
  <div>
    <h1>子组件接受父组件传过来的值:{{ modelValue }}</h1>
    <input type="text" :value="modelValue" v-on:input="inputEvent" />
    <button @click="empty">清空</button>
  </div>
</template>

<script setup lang="ts">
const emits = defineEmits(['input'])
const props = withDefaults(
  defineProps<{
    modelValue: string //参数必传
  }>(),
  {
    modelValue: ''
  }
)

const empty = () => {}
const inputEvent = (e: any) => {
  console.log(e.target.value, 'eeeeee')

  emits('input', e.target.value)
}
</script>

<style scoped></style>
